package com.example.adapter;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;

import java.util.List;

/**
 * Created by 刘智强 on 2016/8/23.
 */
public class PhotoVierPagerAdapter extends PagerAdapter {
    private Context context;
    private List<View> views;

    public PhotoVierPagerAdapter(Context context, List<View> datas) {
        this.context = context;
       this.views=datas;
    }

    @Override
    public int getCount() {
        return views.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {

        return view==object;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {

        ((ViewPager)container).removeView(views.get(position));

    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {

        ((ViewPager)container).addView(views.get(position),0);
        return views.get(position);
    }
}
